﻿using System;
using System.Collections.Generic;
using System.Text;
using Evaluant.Uss.ObjectContext;
using Evaluant.Uss.Xml;
using Evaluant.Uss;

namespace BasicApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            // Creates a new XmlProvider isntance
            XmlProvider provider = new XmlProvider();

            provider.FileName = "euss.xml";
            provider.RegisterMetaData(MetaDataFactory.FromAssembly("ProgrammaticConfiguration"));

            // Initilizes the provider using the given configuration properties
            provider.InitializeConfiguration();

            ObjectService os = new ObjectService(provider);
            ObjectContext oc = os.CreateObjectContext();

            // Deletes any already existing content and creates 
            // necessary resources
            oc.InitializeRepository();

            Customer c1 = new Customer();
            c1.Name = "Customer One";
            c1.Address = "1 Customer One Avenue";

            oc.BeginTransaction();
            oc.Serialize(c1);
            oc.CommitTransaction();

            foreach (Customer c in oc.Load<Customer>(typeof(Customer)))
            {
                Console.WriteLine("Customer: {0} [{1}]", c.Name, c.Address);
            }
        }
    }
}
